package com.gewu.pm.ui.adapter.sales;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.gewu.pm.R;
import com.gewu.pm.app.AppAdapter;

/**
 * 拜访记录适配器（简化版，只显示拜访人名字）
 */
public class VisitRecordAdapter extends AppAdapter<String> {

    public VisitRecordAdapter(Context context) {
        super(context);
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ItemViewHolder();
    }

    private final class ItemViewHolder extends AppAdapter<?>.ViewHolder {

        private final TextView mVisitDateView;
        private final TextView mVisitorNameView;
        private final TextView mVisitPurposeView;
        private final TextView mVisitSummaryView;
        private final TextView mArrivalTimeView;
        private final TextView mEndTimeView;

        private ItemViewHolder() {
            super(R.layout.visit_record_item);
            mVisitDateView = findViewById(R.id.tv_visit_date);
            mVisitorNameView = findViewById(R.id.tv_visitor_name);
            mVisitPurposeView = findViewById(R.id.tv_visit_purpose);
            mVisitSummaryView = findViewById(R.id.tv_visit_summary);
            mArrivalTimeView = findViewById(R.id.tv_arrival_time);
            mEndTimeView = findViewById(R.id.tv_end_time);
        }

        @Override
        public void onBindView(int position) {
            String visitorName = getItem(position);
            // 简化版：只显示拜访人名字，其他字段使用固定数据
            mVisitorNameView.setText("拜访人："+visitorName);
            // 以下数据暂时写死，后期可以根据实际需求修改为动态数据
            mVisitDateView.setText("2025-08-12");
            mVisitPurposeView.setText("客户拜访");
            mVisitSummaryView.setText("希望增加更多口味（如五香豆腐）");
            mArrivalTimeView.setText("11:34");
            mEndTimeView.setText("11:34");
        }
    }
}

